<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="./crypto-js.min.js"></script>
    <script>
        let a = "123123";
        let encryptByDES1 = encryptByDES(a, '81cf7ac1356028a5837353124d955b7b');
        console.log(encryptByDES1)

        function encryptByDES(message, key) {
            let keyHex = CryptoJS.enc.Utf8.parse(key);
            console.log(keyHex);
            let encrypted = CryptoJS.DES.encrypt(message, keyHex, {
                mode: CryptoJS.mode.ECB,
                padding: CryptoJS.pad.Pkcs7
            });
            return encrypted.toString();
        }

        function changePswd() {
            let key = document.getElementById("key").value;
            let pswd = document.getElementById("pswd").value;
            let encryptByDES2 = encryptByDES(pswd, key);
            console.log(encryptByDES2);
            document.getElementById("result").innerText=encryptByDES2
        }
    </script>
</head>
<body>
<div>
    密钥：<input id="key" name="key" value="">
</div>
<div>
    密码：<input id="pswd" name="pswd" value="" onchange="changePswd()">
</div>
<div>
    密文：<p id="result"></p>
</div>
</body>
</html>